<html>
<head><meta charset="utf-8"><title>error[E0642]: patterns aren&#x27;t allowed in methods without bod · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren&#x27;t.20allowed.20in.20methods.20without.20bod.html">error[E0642]: patterns aren&#x27;t allowed in methods without bod</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="234447763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/error%5BE0642%5D%3A%20patterns%20aren%27t%20allowed%20in%20methods%20without%20bod/near/234447763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren&#x27;t.20allowed.20in.20methods.20without.20bod.html#234447763">(Apr 14 2021 at 06:32)</a>:</h4>
<p>Compiling Servo with a recent Nightly fails with:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">error</span><span class="p">[</span><span class="n">E0642</span><span class="p">]</span>: <span class="nc">patterns</span><span class="w"> </span><span class="n">aren</span><span class="o">'</span><span class="na">t</span><span class="w"> </span><span class="n">allowed</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">methods</span><span class="w"> </span><span class="n">without</span><span class="w"> </span><span class="n">bodies</span><span class="w"></span>
<span class="w">    </span><span class="o">-</span>-&gt; <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">simon</span><span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">cargo</span><span class="o">-</span><span class="n">home</span><span class="o">/</span><span class="n">registry</span><span class="o">/</span><span class="n">src</span><span class="o">/</span><span class="n">github</span><span class="p">.</span><span class="n">com</span><span class="o">-</span><span class="mi">1</span><span class="n">ecc6299db9ec823</span><span class="o">/</span><span class="n">clang</span><span class="o">-</span><span class="n">sys</span><span class="o">-</span><span class="mf">0.29.3</span><span class="o">/</span><span class="n">src</span><span class="o">/</span><span class="n">lib</span><span class="p">.</span><span class="n">rs</span>:<span class="mi">2186</span>:<span class="mi">46</span><span class="w"></span>
<span class="w">     </span><span class="o">|</span><span class="w"></span>
<span class="mi">2186</span><span class="w"> </span><span class="o">|</span><span class="w">     </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">clang_VerbatimLineComment_getText</span><span class="p">(</span><span class="n">comment</span>: <span class="nc">CXComment</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">CXString</span><span class="p">;</span><span class="w"></span>
<span class="w">     </span><span class="o">|</span><span class="w">                                              </span><span class="o">^^^^^^^</span><span class="w"></span>
<span class="w">     </span><span class="o">|</span><span class="w"></span>
<span class="n">help</span>: <span class="nc">give</span><span class="w"> </span><span class="n">this</span><span class="w"> </span><span class="n">argument</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="n">name</span><span class="w"> </span><span class="n">or</span><span class="w"> </span><span class="k">use</span><span class="w"> </span><span class="n">an</span><span class="w"> </span><span class="n">underscore</span><span class="w"> </span><span class="n">to</span><span class="w"> </span><span class="n">ignore</span><span class="w"> </span><span class="n">it</span><span class="w"></span>
<span class="w">     </span><span class="o">|</span><span class="w"></span>
<span class="mi">2186</span><span class="w"> </span><span class="o">|</span><span class="w">     </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">clang_VerbatimLineComment_getText</span><span class="p">(</span><span class="n">_</span>: <span class="nc">CXComment</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">CXString</span><span class="p">;</span><span class="w"></span>
</code></pre></div>



<a name="234447872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/error%5BE0642%5D%3A%20patterns%20aren%27t%20allowed%20in%20methods%20without%20bod/near/234447872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren&#x27;t.20allowed.20in.20methods.20without.20bod.html#234447872">(Apr 14 2021 at 06:33)</a>:</h4>
<p>It looks like a deprecation warning was turned into a hard error independent of editions. Couldn’t this breaking change have been edition-conditional?</p>



<a name="234448599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/error%5BE0642%5D%3A%20patterns%20aren%27t%20allowed%20in%20methods%20without%20bod/near/234448599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren&#x27;t.20allowed.20in.20methods.20without.20bod.html#234448599">(Apr 14 2021 at 06:39)</a>:</h4>
<p>How is that a pattern?</p>



<a name="234448861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/error%5BE0642%5D%3A%20patterns%20aren%27t%20allowed%20in%20methods%20without%20bod/near/234448861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren&#x27;t.20allowed.20in.20methods.20without.20bod.html#234448861">(Apr 14 2021 at 06:42)</a>:</h4>
<p>Also a good question. clang-sys is macro heavy so I’m trying to figure that out…</p>



<a name="234448925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/error%5BE0642%5D%3A%20patterns%20aren%27t%20allowed%20in%20methods%20without%20bod/near/234448925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren&#x27;t.20allowed.20in.20methods.20without.20bod.html#234448925">(Apr 14 2021 at 06:43)</a>:</h4>
<p><a href="https://github.com/KyleMayes/clang-sys/blob/v0.29.3/src/lib.rs#L1659">https://github.com/KyleMayes/clang-sys/blob/v0.29.3/src/lib.rs#L1659</a> is where the error spans point</p>



<a name="234451267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/error%5BE0642%5D%3A%20patterns%20aren%27t%20allowed%20in%20methods%20without%20bod/near/234451267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren&#x27;t.20allowed.20in.20methods.20without.20bod.html#234451267">(Apr 14 2021 at 07:06)</a>:</h4>
<p>It’s also not a method as far as I can tell…</p>



<a name="234452244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/error%5BE0642%5D%3A%20patterns%20aren%27t%20allowed%20in%20methods%20without%20bod/near/234452244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren&#x27;t.20allowed.20in.20methods.20without.20bod.html#234452244">(Apr 14 2021 at 07:16)</a>:</h4>
<p>this is also affecting wasmtime/cranelift <a href="https://github.com/bytecodealliance/wasmtime/pull/2829/checks?check_run_id=2332860293">https://github.com/bytecodealliance/wasmtime/pull/2829/checks?check_run_id=2332860293</a> and they have now pinned their CI to another recent nightly</p>



<a name="234454521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/error%5BE0642%5D%3A%20patterns%20aren%27t%20allowed%20in%20methods%20without%20bod/near/234454521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren&#x27;t.20allowed.20in.20methods.20without.20bod.html#234454521">(Apr 14 2021 at 07:37)</a>:</h4>
<p>this is tracked in <a href="https://github.com/rust-lang/rust/issues/84162">#84162</a> and will be fixed by <a href="https://github.com/rust-lang/rust/issues/84130">#84130</a></p>



<a name="234459144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/error%5BE0642%5D%3A%20patterns%20aren%27t%20allowed%20in%20methods%20without%20bod/near/234459144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren&#x27;t.20allowed.20in.20methods.20without.20bod.html#234459144">(Apr 14 2021 at 08:14)</a>:</h4>
<p>Oh, nice! I was trying to reduce but looks like I don’t need to. Thanks <span class="user-mention" data-user-id="116113">@lqd</span></p>



<a name="234506041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/error%5BE0642%5D%3A%20patterns%20aren%27t%20allowed%20in%20methods%20without%20bod/near/234506041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren&#x27;t.20allowed.20in.20methods.20without.20bod.html#234506041">(Apr 14 2021 at 14:17)</a>:</h4>
<p><span class="user-mention silent" data-user-id="219747">Simon Sapin</span> <a href="#narrow/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren't.20allowed.20in.20methods.20without.20bod/near/234447872">said</a>:</p>
<blockquote>
<p>It looks like a deprecation warning was turned into a hard error independent of editions. Couldn’t this breaking change have been edition-conditional?</p>
</blockquote>
<p>for bugfixes AFAIK it is pretty common to turn future-incompat lints into hard errors without edition boundary?</p>



<a name="234507516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/error%5BE0642%5D%3A%20patterns%20aren%27t%20allowed%20in%20methods%20without%20bod/near/234507516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren&#x27;t.20allowed.20in.20methods.20without.20bod.html#234507516">(Apr 14 2021 at 14:26)</a>:</h4>
<p>I don’t know if I’d call it “common.” Its something we certainly <em>want</em> to do more often. Being able to increase the number of future-incompat lints that become hard-errors was a big motivation for me in writing <a href="https://github.com/rust-lang/rfcs/issues/2834">rfcs#2834</a> (tracked in <a href="https://github.com/rust-lang/rust/issues/71249">rust#71249</a>)</p>



<a name="234523495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/error%5BE0642%5D%3A%20patterns%20aren%27t%20allowed%20in%20methods%20without%20bod/near/234523495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren&#x27;t.20allowed.20in.20methods.20without.20bod.html#234523495">(Apr 14 2021 at 15:46)</a>:</h4>
<p>I think it would be worth a case-by-case evaluation. If a lint is for a potential soundness issue that sounds justified to be relatively aggressive. As far as I can tell though, the thing about patterns in method parameters is mostly stylistic and making the language easier to teach? It doesn’t seem worth pushing the ecosystem through a breaking change, even with mitigations like <a href="https://github.com/rust-lang/rfcs/pull/2834">https://github.com/rust-lang/rfcs/pull/2834</a></p>



<a name="234531073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/error%5BE0642%5D%3A%20patterns%20aren%27t%20allowed%20in%20methods%20without%20bod/near/234531073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren&#x27;t.20allowed.20in.20methods.20without.20bod.html#234531073">(Apr 14 2021 at 16:31)</a>:</h4>
<p>(This example is hypothetical since <a href="https://github.com/rust-lang/rust/issues/84162">https://github.com/rust-lang/rust/issues/84162</a> was an unintentional bug and being fixed)</p>



<a name="234534578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/error%5BE0642%5D%3A%20patterns%20aren%27t%20allowed%20in%20methods%20without%20bod/near/234534578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren&#x27;t.20allowed.20in.20methods.20without.20bod.html#234534578">(Apr 14 2021 at 16:52)</a>:</h4>
<p>I agree with <span class="user-mention" data-user-id="219747">@Simon Sapin</span> on this point; I'd like to see us formulating a fresh policy around breaking changes etc</p>



<a name="234534846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/error%5BE0642%5D%3A%20patterns%20aren%27t%20allowed%20in%20methods%20without%20bod/near/234534846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren&#x27;t.20allowed.20in.20methods.20without.20bod.html#234534846">(Apr 14 2021 at 16:54)</a>:</h4>
<p>I think we already do have a couple RFCs on this? But refining what is considered a major or minor change sounds good</p>



<a name="234535132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/error%5BE0642%5D%3A%20patterns%20aren%27t%20allowed%20in%20methods%20without%20bod/near/234535132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren&#x27;t.20allowed.20in.20methods.20without.20bod.html#234535132">(Apr 14 2021 at 16:55)</a>:</h4>
<p>we do, but I think that we can be a lot more specific now; this is related to the work that <span class="user-mention" data-user-id="224872">@rylev</span> and I were doing on lint policy etc</p>



<a name="234535214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/error%5BE0642%5D%3A%20patterns%20aren%27t%20allowed%20in%20methods%20without%20bod/near/234535214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren&#x27;t.20allowed.20in.20methods.20without.20bod.html#234535214">(Apr 14 2021 at 16:56)</a>:</h4>
<p>I personally think it may be time for us to be tighter</p>



<a name="234536910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/error%5BE0642%5D%3A%20patterns%20aren%27t%20allowed%20in%20methods%20without%20bod/near/234536910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren&#x27;t.20allowed.20in.20methods.20without.20bod.html#234536910">(Apr 14 2021 at 17:06)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/213817-t-lang/topic/error.5BE0642.5D.3A.20patterns.20aren't.20allowed.20in.20methods.20without.20bod/near/234535214">said</a>:</p>
<blockquote>
<p>I personally think it may be time for us to be tighter</p>
</blockquote>
<p>what does that mean for <a href="https://github.com/rust-lang/rust/issues/71800">https://github.com/rust-lang/rust/issues/71800</a> ?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>